#define _CRT_SECURE_NO_WARNINGS 1
//#include<iostream>
//#include<algorithm>
//#include<vector>
//using namespace std;
////
////int main()
////{
////
////	int i = 1;
////	if (i == 2)
////		printf("2");
////	else 
////		printf("3");
////	return 0;
////}
////class Solution {
////public:
////    int singleNumber(vector<int>& nums) {
////        size_t n = nums.size();
////        int i;
////        if (n == 1)
////            return nums[0];
////        for (i = 0; i < n; i++)
////        {
////            if (i == 0 && nums[i] != nums[i + 1])
////                return nums[0];
////            else if (i == n - 1 && nums[n - 1] != nums[n - 2])
////                return nums[n - 1];
////            else if (i > 0 && i < n && nums[i] != nums[i - 1]
////                && nums[i] != nums[i + 1])
////                return nums[i];
////        }
////        return 0;
////    }
////};
//int main()
//{
//	/*vector<string> v;
//	v.push_back("aaa");
//	v.push_back("aa");
//	v.push_back("b");
//	sort(v.begin(), v.end());
//	
//	for (int i = 0; i < v.size(); i++)
//	{
//		cout << v[i] << endl;
//	}*/
//	int i = 1;
//	if (i > 3)
//	{
//		cout << "true" << endl;
//	}
//	else if (i < 2)
//	{
//		cout << "false" << endl;
//	}
//	return 0;
//}
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
bool Sort(vector<string>& v)
{
    vector<string> v1(v.begin(), v.end());
    sort(v1.begin(), v1.end());
    for (int i = 0; i < v1.size(); i++)
    {
        if (v[i] != v1[i])
        {
            return false;
        }
    }
    return true;
}
bool Better(vector<string>& v)
{
    for (int i = 1; i < v.size(); i++)
    {
        if (v[i - 1].size() > v[i].size())
        {
            return false;
        }
    }
    return true;
}
int main()
{
    vector<string> v;
    int n = 0;
    cin >> n;
    v.resize(n);
    for (int i = 0; i < n; i++)
    {
        getline(cin, v[i]);
    }
    if (Sort(v) && Better(v))
    {
        cout << "both" << endl;
    }
    else if (Sort(v))
    {
        cout << "lexicographically" << endl;
    }
    else if (Better(v))
    {
        cout << "lengths" << endl;

    }
    else {
        cout << "none" << endl;
    }

}